package com.learn.thread;

/**
 * 多线程的实现原理（增强版的静态代理）
 */
public class DemoThread25110203 {
    public static void main(String[] args) {
        new MarryProxy(new You()).marry();
        new Thread(()-> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName()+i);
            }
        }).start();
    }
}

interface Marry {
    void marry();
}

class You implements Marry {
    @Override
    public void marry() {
        System.out.println("you is marrying...");
    }
}

class MarryProxy implements Marry {
    private Marry marry;

    public MarryProxy(Marry marry) {
        this.marry = marry;
    }

    @Override
    public void marry() {
        System.out.println("婚介公司，结婚之前要做的事情>>>>");
        marry.marry();
        System.out.println("婚介公司，结婚之后要做的事情>>>>");
    }
}